﻿
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>诊疗卡</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weui.css" />
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weuix.css" />
    <link href="/customer/css/blue.css" rel="stylesheet" />
    <script src="/lobsteruiframe/weui/js/zepto.min.js"></script>
    <script src="/lobsteruiframe/weui/js/zepto.weui.js"></script>
    <script src="/lobsteruiframe/weui/js/php.js"></script>
    <script src="/jslib/template-web.js"></script>
    <script src="/jslib/lobster.js"></script>
    <style type="text/css">
        .tips_0903 {
            /*            background-color: #c8ddf6;*/
            overflow: hidden;
            padding: 10px 0;
        }

        .tipCon {
            padding: 5px 20px;
            width: 100%;
            box-sizing: border-box;
            font-size: 17px;
            line-height: 28px;
            color: #666;
        }

        .textBlue {
            color: #4990e2;
        }
    </style>
    
</head>

<body ontouchstart>
    <div class="tips_0903 bg-gray">
        <!-- 温馨提示 -->
        <div class='tips'>
            <div class='tipCon'>
                <text class='page-hd-desc'>本院实行实名制就诊，请如实填写就诊人信息，若实际信息与填写信息不符，将会影响患者正常咨询及正常就医。</text>
                <div class='clear'></div>
            </div>
        </div>
    </div>
    <div class="weui-cells weui-cells_form">

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入姓名" id="txtusername">
            </div>
        </div>
        <!--<div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">证件类型</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" id="identity" type="text" value="">
            </div>
        </div>-->

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">身份证</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入身份证号码" id="txtidcard">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">性别</label></div>
            <div class="weui-cell__bd">
                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="f2" id="g1" type="radio" checked="checked">
                    <label for="g1">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">男</div>
                    </label>
                </div>

                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="f2" id="g2" type="radio">
                    <label for="g2">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">女</div>
                    </label>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">出生日期</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" id="txtbirthday" type="text" value="" placeholder="请选择出生日期">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">是否默认</label></div>
            <div class="weui-cell__bd">
                <input class="weui-switch" type="checkbox" id="isdefault">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" id="txtmobile" placeholder="请输入手机号">
            </div>
        </div>
    </div>




    <div class="weui-btn-area">
        <a class="weui-btn weui-btn_primary" href="javascript:" id="btn">确定</a>
    </div>
</body>
</html>



<script>
    lobsterh5.main({
        data: {
        },
        pageload() {
            this.initEvent();
        },
        initEvent() {
            var self = this;
            self.initBirthday();

            $("#btn").click(function () {
                self.savedata();
            });
        },
        initBirthday() {
            $("#txtbirthday").datetimePicker({
                title: '生日',
                years: range(1940, 2030),
                times: function () { return []; },
                parse: function (str) {
                    return str.split("-");
                },
                onChange: function (picker, values, displayValues) {
                    console.log(values);
                }
            });
        },

        savedata() {
            console.log("savedata");
            var self = this;
            var name = $("#txtusername").val();
            //var code = self.data.idcode;
            var idcard = $("#txtidcard").val();
            var man = $("#g1").is(":checked");
            var woman = $("#g2").is(":checked");
            var sex = woman ? 1 : 0;
            var birthday = $("#txtbirthday").val();
            var isdefault = $("#isdefault").is(":checked") ? 1 : 0; //$("#isdefault").val();
            var mobile = $("#txtmobile").val();
            //var yzmcode = $("#txtcode").val();
            if (!name) {
                $.toast('请输入姓名', 'text');
                return;
            }
            if (!idcard) {
                $.toast('证件号码', 'text');
                return;
            }
            if (!birthday) {
                $.toast('请输入出生日期', 'text');
                return;
            }
            if (!mobile) {
                $.toast('请输入手机号码', 'text');
                return;
            }

            var patient = {};

            patient.Name = name.replace(/(^\s*)|(\s*$)/g, "");
            patient.Sex = sex;
            patient.IDCard = idcard;//身份证号码
            patient.Birthday = birthday;
            patient.Phone = mobile;
            patient.DefaultFlag = isdefault;


            lobsterh5.POST("/admin/v1/CPatient/SavePatientData", patient).then(res => {
                console.log(res);
                location.replace("patient.html?WorkId=" + lobsterh5.GetWorkId());
                // history.back(-1);
                //location.reload();
            }).catch(res => {
                console.log(res);
                $.toast(res.msg || "操作失败", "forbidden");
            });
        },
    });
</script>